# -*- coding: utf-8 -*-
import scrapy


class BbSpider(scrapy.Spider):
    name = 'bb'
    allowed_domains = ['bilibili.com']
    start_urls = ['https://www.bilibili.com/v/dance/otaku/?spm_id_from=333.334.b_7072696d6172795f6d656e75.34#/']

    def parse(self, response):
        # 分组
        li_list = response.xpath('//ul[@class="vd-list mod-2"]/li')
        print(li_list)
        for li in li_list:
            item = {}
            item['img'] = li.xpath('.//div/div[1]//img/@src').extract_first()
            item['href'] = li.xpath('//div/div[2]/a/@href').extract_first()
            item['title'] = li.xpath('.//div/div[2]/a/text()').extract_first()
            item['play_volume'] = li.xpath('.//div/div[2]/div/span[1]//text()').extract_first()
            item['barrage'] = li.xpath('.//div/div[2]/div[2]/span[2]//text()').extract_first()
            item['up_name'] = li.xpath('.//div/div[2]/div[3]/a/text()').extract_first()
            yield item


